package com.raising.modules.sys.entity;


import com.raising.framework.entity.BaseEntity;
import com.raising.modules.sys.entity.enums.ResourceEnum;

import java.util.List;

/**
 * 资源表
 * 
 * @author gaoy
 */
public class Resource extends BaseEntity<Resource> {

	private static final long serialVersionUID = 1L;
	/** 资源名称 */
	private String name;
	/** 资源类型 */
	private ResourceEnum type = ResourceEnum.menu;
	/** 图标 */
	private String icon;
	/** 资源路径 */
	private String url;
	/** 权限字符串 */
	private String permission;
	/** 父编号 */
	private String parentId;
	/** 上级资源 */
	private Resource resource;
	/** 下级资源 */
	private List<Resource> child;
	/** 父编号列表 */
	private String parentIds;
	/** 排序 */
	private int sort=0;
	/** 是否可用 */
	private Boolean available = Boolean.TRUE;

	public Resource() {
		super();
	}

	public Resource(String id) {
		super(id);
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public ResourceEnum getType() {
		return type;
	}

	public void setType(ResourceEnum type) {
		this.type = type;
	}

	public String getIcon() {
		return icon;
	}

	public void setIcon(String icon) {
		this.icon = icon;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public String getPermission() {
		return permission;
	}

	public void setPermission(String permission) {
		this.permission = permission;
	}

	public String getParentId() {
		return parentId;
	}

	public void setParentId(String parentId) {
		this.parentId = parentId;
	}

	public String getParentIds() {
		return parentIds;
	}

	public void setParentIds(String parentIds) {
		this.parentIds = parentIds;
	}

	public int getSort() {
		return sort;
	}

	public void setSort(int sort) {
		this.sort = sort;
	}

	public Boolean getAvailable() {
		return available;
	}

	public void setAvailable(Boolean available) {
		this.available = available;
	}

	public boolean isRootNode() {
		return parentId.equals("0");
	}

	public String makeSelfAsParentIds() {
		return getParentIds() + getId() + "/";
	}

	public Resource getResource() {
		return resource;
	}

	public void setResource(Resource resource) {
		this.resource = resource;
	}

	public List<Resource> getChild() {
		return child;
	}

	public void setChild(List<Resource> child) {
		this.child = child;
	}

	@Override
	public String toString() {
		return "Resource{" +
				"name='" + name + '\'' +
				", type=" + type +
				", icon='" + icon + '\'' +
				", url='" + url + '\'' +
				", permission='" + permission + '\'' +
				", parentId='" + parentId + '\'' +
				", resource=" + resource +
				", child=" + child +
				", parentIds='" + parentIds + '\'' +
				", sort=" + sort +
				", available=" + available +
				'}';
	}
}
